package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.model.Auth;
import com.tencent.wxcloudrun.response.R;
import com.tencent.wxcloudrun.service.AuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: AuthController
 * Package: com.tencent.wxcloudrun.controller
 * Description:
 *
 * @Date: 2023/1/22 8:34 AM
 * @Author: wht
 */
@Slf4j
@RestController
//@RestController = @Controller + @ResponseBody
@RequestMapping("/admin")
public class AuthController {
    @Autowired
    AuthService authService;


    @PutMapping("/addOneAuth")
    public <T> R<T> addOneAuth(@RequestBody Auth auth) {
        authService.addOneAuth(auth);
        return R.successMsg("添加成功！");
    }

    @PatchMapping("/updateOneAuthById")
    public <T> R<T> updateOneAuthById(@RequestBody Auth auth) {
        authService.updateOneAuthById(auth);
        return R.successMsg("修改成功！");
    }

    @GetMapping("/getAuthListAll")
    public <T> R<T> getAuthListAll() {
        List<Auth> res = authService.getAuthListAll();
        return R.successData(res);
    }
}
